home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
cislib_a
/
index.doc
< prev
next >
Wrap
Text File
|
1995-04-22
|
2KB
|
66 lines
INDEX
INDEX is a high-performance BASIC subroutine to search a string for a
substring. It works much like the PL/I INDEX function. (See DEMONSTRATION
below.)
IMPORTANT NOTES
1. INDEX is fully self-relocatable, so it may be moved anywhere in memory.
2. INDEX is useful for scanning a string for certain characters(s). Note
that the string to be searched can also be a substring of a longer string.
3. The search argument substring will normally be shorter than the string to
be searched.
CALLING
RETURNCODE=USR(INDEX, STRADR, SUBADR, STRLEN, ADRLEN)
INDEX: The address of the INDEX subroutine [usually ADR(INDEXSTRING$)].
STRADR: Address of the string to be searched [usually ADR(DATASTRING1$)].
SUBADR: Address of the search substring [usually ADR(DATASTRING2$)].
STRLEN: Length of the string to be searched [usually LEN(DATASTRING1$)].
SUBLEN: Length of the search substring [usually LEN(DATASTRING2$)].
RETURN CODES
0 Substring not found.
>0 Leftmost position of the substring in string (first position is 1).
DEMONSTRATION
INDEX.BIN is a simple tokenized BASIC (binary) program which will demonstrate
the INDEX subroutine. You may type both a string and a search substring. For
example the string "NOW IS THE TIME" will give a return code of 5 when searched
with "IS".
USE
To use the subroutine, just transfer the statements 900-904 to your own
program (you could do a LIST "D:TEMP",900,904 from the demo followed by an ENTER
"D:TEMP" into your own program); of course, you can renumber the statements as
necessary. Remember to call the subroutine once at the beginning of your program
to set it up.
-John Navas [72645,1070]